package xdu.lz.stage1_basic.chapter1_threadsafe.deadLock;

public class DeadLock {
    public static void main(String[] args) {
        new Thread(()->{
            while (true){
                synchronized ("A"){
                    synchronized ("B"){
//                        try {
//                            Thread.sleep(10L);
//                        } catch (InterruptedException e) {
//                            e.printStackTrace();
//                        }
                        System.out.println(Thread.currentThread().getName()+":AB");
                    }
                }
            }
        }).start();
        new Thread(()->{
            while (true){
                synchronized ("B"){
                    try {
                        Thread.sleep(10L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    synchronized ("A"){
                        System.out.println(Thread.currentThread().getName()+":BA");
                    }
                }
            }
        }).start();
    }
}
